package org.example;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;

//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    public static void main(String[] args) {
       MyThreadPool  myThreadPool=new MyThreadPool(2,4,5,TimeUnit.SECONDS,new ArrayBlockingQueue<>(3),new DiscardRejectHandler());
        for (int i = 0; i <8 ; i++) {
            final  int fi=i;
            myThreadPool.execute(()->{
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println(Thread.currentThread().getName()+"   "+ fi);
            });
        }
        System.out.println("主线程没有被阻塞");
    }
}
